package com.ruiya.staging.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.context.ApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;

@EnableDiscoveryClient
@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {
    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(ConfigServerApplication.class, args);

        // 测试用数据
        JdbcTemplate jdbcTemplate = context.getBean(JdbcTemplate.class);
        jdbcTemplate.execute("delete from properties");
        jdbcTemplate.execute("INSERT INTO properties VALUES(5, 'datasource-driver-class-name', 'MyDriverClass', 'appplication1', 'production', 'latest')");

        //debug test data
        jdbcTemplate.execute("INSERT INTO properties VALUES(8, 'test.name', 'dev-abc', 'goods-data-io', 'dev', 'latest')");
        jdbcTemplate.execute("INSERT INTO properties VALUES(9, 'test.name', 'test-abc', 'goods-data-io', 'test', 'latest')");

        //goods-data-io :: db
        jdbcTemplate.execute("INSERT INTO properties VALUES(100, 'goods.dataio.mysql.url', 'mysql://root:123456@localhost:3306/goodsdb?serverTimezone=GMT%2B8&nonce=123', 'goods-data-io', 'dev', 'latest')");

        //testdb
        jdbcTemplate.execute("INSERT INTO properties VALUES(101, 'goods.dataio.testdb.url', 'mysql://root:123456@localhost:3306/testdb?serverTimezone=GMT%2B8', 'goods-data-io', 'dev', 'latest')");

    }
}
